<?php 
	require('ConnectionDB.php');
	include('BeanSala.php');

	class DAOSalas extends ConnectionDB{
		private $aSalas;
		
		public function _construct(){
			parent::__construct();
			$this->aSalas = array();
		}
		
		public function getListaSalas(){
			$this->sQuery = "SELECT * FROM salas";
			$oResult = mysql_query($this->sQuery);
			
			if($oResult && mysql_num_rows($oResult) > 0){
				while($aRow = mysql_fetch_row($oResult)){
					$oSala = new BeanSala($aRow[0],$aRow[1],$aRow[2],$aRow[3],$aRow[4]);
					$this->aSalas[] = $oSala;
				}
			}
			mysql_free_result($oResult);
				
			return $this->aSalas;
		}
		
		public function getSalaById($iId){
			$this->sQuery = "SELECT * FROM salas WHERE id_sala = '$iId'";
			$oResult = mysql_query($this->sQuery);
			
			if($oResult && mysql_num_rows($oResult) > 0){
				while($aRow = mysql_fetch_row($oResult)){
					$oSala = new BeanSala($aRow[0],$aRow[1],$aRow[2],$aRow[3],$aRow[4]);
					$this->aSalas[] = $oSala;
				}
			}
			mysql_free_result($oResult);
				
			return $this->aSalas;
		}	
	}
?>